/**
 * 获取当前页面目录
 */
 function getUrlPath(){  
　var url = document.location.toString();               
　if(url.indexOf("/") != -1){  
         url = url.substring(0,  url.lastIndexOf("/")+1) ;  
　}  
　return url;  
}  

 /**
	 * 获取当前js路径
	 */
 function getJsUrlPath(){
	return window.UEDITOR_HOME_URL || getUEBasePath();
 }
  
 function getUEBasePath(docUrl, confUrl) {
     return getBasePath(docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath());
 }
 
 function getConfigFilePath() {
     var configPath = document.getElementsByTagName('script');
     return configPath[ configPath.length - 1 ].src;
 }

 function getBasePath(docUrl, confUrl) {
     var basePath = confUrl;
     if (/^(\/|\\\\)/.test(confUrl)) {
         basePath = /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/, '');
     } else if (!/^[a-z]+:/i.test(confUrl)) {
         docUrl = docUrl.split("#")[0].split("?")[0].replace(/[^\\\/]+$/, '');
         basePath = docUrl + "" + confUrl;
     }
     return optimizationPath(basePath);
 }

 function optimizationPath(path) {
     var protocol = /^[a-z]+:\/\//.exec(path)[ 0 ],
         tmp = null,
         res = [];
     path = path.replace(protocol, "").split("?")[0].split("#")[0];
     path = path.replace(/\\/g, '/').split(/\//);
     path[ path.length - 1 ] = "";
     while (path.length) {
         if (( tmp = path.shift() ) === "..") {
             res.pop();
         } else if (tmp !== ".") {
             res.push(tmp);
         }
     }
     return protocol + res.join("/");
 }
 
 
 $.extend({
	 include: function(url,file) {
		 var files = typeof file == "string" ? [file]:file;
		 for (var i = 0; i < files.length; i++) {
			 var name = files[i];
			 var att = name.split('.');
			 var ext = att[att.length - 1].toLowerCase();
			 var isCSS = ext == "css";
			 var tag = isCSS ? "link" : "script";
			 var attr = isCSS ? " type='text/css' rel='stylesheet' " : " language='javascript' type='text/javascript' ";
			 var link = (isCSS ? "href" : "src") + "='" + url + name + "'";
			 if ($(tag + "[" + link + "]").length == 0) document.write("<" + tag + attr + link + "></" + tag + ">");
		 }
	 }
});

 /**
  * 获取from表单的数据
  * @param form
  * @returns
  */
function getFormData(form){
	var all = $(form).serializeArray();
    var obj = {};
    $.each(all,function(){
      if(this.name && obj[this.name]){
        if(this.value){
            obj[this.name] = obj[this.name]+","+this.value;
        }
      }else if(this.name){
        if(this.value){
          obj[this.name] = this.value;
        }
      }
    })
    
    return obj;
}